package me.zhengjie.modules.equipment.repository;

import me.zhengjie.modules.equipment.domain.TEquipment;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
* @author sw
* @date 2019-06-29
*/
public interface TEquipmentRepository extends JpaRepository<TEquipment, Integer>, JpaSpecificationExecutor {

    //TODO 这里字段是否有问题,已customerid为主?
    @Query("select t from TEquipment t where t.supplier = ?1")
    List<TEquipment> getEqByCustomerId(String id);


    @Query(value = "select t from TEquipment t where t.eqptcode like %?1% or t.eqptname like %?2%")
    List<TEquipment> findByEqptcodeLikeOrEqptnameLike(String code, String code2);


    @Query(value = "select t from TEquipment t where (t.eqptcode like %?1% or t.eqptname like %?1%) and supplier=?2")
    List<TEquipment> findByEqptByCodeAndCustomer(String code, String supplier);
}